/**
 * @brief common stuff header
 * @author Gilad Avidov
 */
#ifndef COMMON_H_INCLUDED
#define COMMON_H_INCLUDED

#define BIT(n) (0x1 << (n))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MIN(x,y) (x<y) ? (x) : (y)

/*
 * @return hex value of char (0..9, a..f, A..F)
 *      (or zero on none in range
 */
unsigned char get_hex_val(char ch);
unsigned int calc_hex_num(const char *str, unsigned char len);

/* from serial */
unsigned int get_hex_num();

/* from serial */
unsigned long get_num();
/*
 * from serial
 * @return string length
 */
unsigned short get_str(char *str, unsigned short len);

#endif // COMMON_H_INCLUDED
